function ga2(popsize,dimension,stringlength,x_bound,matlast,mat2dpoints,I,Im)%default pm = 0.05
%popsize=200;dimension=2;stringlength=8;x_bound=[0,1;0,13];
pm=0.05; 
pop=encodi(popsize,stringlength,dimension); 
pop=decoding(pop,stringlength,dimension,x_bound,matlast,mat2dpoints,I,Im);
[choice_number,choice_k]=max(pop(:,stringlength*dimension+1)) ;
%fprintf('pase');
%choice=pop(choice_k,:)

%[choice_number,choice_k]=max(pop(:,stringlength*dimension+1)); 
choice=pop(choice_k,:);
%fprintf('pase');
for i=1:20
    %fprintf('pase iteracion');
    new_pop=cross_over(pop,popsize,stringlength,dimension); 
    
    %fprintf('pase crosover');
    pop=mutation(new_pop,stringlength,dimension,pm); 
    size(pop,1);
    %fprintf('pase');
    pop=decoding(pop,stringlength,dimension,x_bound,matlast,mat2dpoints,I,Im); 
    [number,k]=max(pop(:,stringlength*dimension+1)); 
        if choice_number<number 
            choice_number=number; 
            choice_k=k; 
            choice=pop(choice_k,:); 
        end
    pop=selection(pop,popsize,stringlength,dimension);
    size(pop,1);
    [number,m]=min(pop(:,stringlength*dimension+1)); 
    pop(m,:)=choice; 
end
[value,x]=result(pop,stringlength,dimension,x_bound,matlast,mat2dpoints,I,Im)

end